package com.example.myapplication.acty;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.example.myapplication.R;
import com.example.myapplication.util.MySQLConnection;
import com.mysql.jdbc.Connection;

import java.sql.PreparedStatement;

public class RegActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reg);
        EditText et_name = findViewById(R.id.et_name);
        EditText et_pass = findViewById(R.id.et_pass);
        findViewById(R.id.btn_register).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //注册
                if (TextUtils.isEmpty(et_name.getText().toString().trim()) || TextUtils.isEmpty(et_pass.getText().toString().trim())) {
                    Toast.makeText(RegActivity.this, "账号密码不能为空", Toast.LENGTH_SHORT).show();
                    return;
                }
                if (register(et_name.getText().toString().trim(), et_pass.getText().toString().trim())) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(RegActivity.this, "操作成功", Toast.LENGTH_SHORT).show();
                            finish();
                        }
                    });
                }
            }
        });
    }

    public boolean register(String username, String password) {

        return true;
    }
}